package com.leenmvc.core.dao.communal.dataEntity;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * 数据库组
 */
public class DataSourceGroup implements Serializable {

    /**
     * 组名
     */
    private String groupName;

    /**
     * 默认数据源
     */
    private DataSourceFactory defaultSource;

    /**
     * 数据库信息源
     */
    private DataSourceFactory informationSource;

    /**
     * 写数据源
     *
     */
    private DataSourceFactory[] writeSources;

    /**
     * 读数据源
     */
    private DataSourceFactory[] readSources;

    private Map<String, DataSourceFactory> sourceGroupMap = new HashMap<>();

    public String getGroupName() {
        return groupName;
    }

    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }

    public DataSourceFactory getDefaultSource() {
        return defaultSource;
    }

    public void setDefaultSource(DataSourceFactory defaultSource) {
        this.defaultSource = defaultSource;
    }

    public DataSourceFactory[] getWriteSources() {
        return writeSources;
    }

    public void setWriteSources(DataSourceFactory[] writeSources) {
        this.writeSources = writeSources;
    }

    public DataSourceFactory[] getReadSources() {
        return readSources;
    }

    public void setReadSources(DataSourceFactory[] readSources) {
        this.readSources = readSources;
    }

    public DataSourceFactory getInformationSource() {
        return informationSource;
    }

    public void setInformationSource(DataSourceFactory informationSource) {
        this.informationSource = informationSource;
    }

    public void putDataSourceFactory(String sourceName, DataSourceFactory factory) {
        sourceGroupMap.put(sourceName, factory);
    }

    public DataSourceFactory getDataSourceFactory(String sourceName) {
        return sourceGroupMap.get(sourceName);
    }

}


